/*
 *    Copyright 2008 Tim Jansen
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.actorsguildframework.annotations;

/**
 * ConcurrencyModel describes the way concurrency is handled in the actor and its methods.
 */
public enum ConcurrencyModel {
	/**
	 * Specifies a single-threaded model: only one simultaneous thread in the actor is allowed.
	 * All messages will be processed in the order that they have been queued.
	 */
	SingleThreaded,
	/**
	 * Specifies a multi-threaded model: several simultaneous thread can run in the actor.
	 * If only some message methods are declared as MultiThreaded (using @Usage), then those
	 * methods can have several threads while the SingleThreaded methods can have only one
	 * simultanous thread per actor.
	 * The order of execution for multi-threaded messages is not defined. 
	 */
	MultiThreaded,
	/**
	 * Specifies a stateless model: several simultaneous thread can run in the actor. 
	 * Unlike {@link #MultiThreaded}, the framework will check that the method does not access any local
	 * fields that are not 'static final'. If the whole actor is Stateless (without any exceptions),
	 * then the framework will check that the Actor class does not have any fields but 'static final'.
	 * The order of execution for stateless messages is not defined. 
	 */
	Stateless;
	
	/**
	 * Returns true if this model is multi-threaded, and thus either {@link #MultiThreaded} or 
	 * {@link #Stateless}.
	 * @return true for multi-threaded models, false otherwise
	 */
	public boolean isMultiThreadingCapable() {
		return this == MultiThreaded || this == Stateless;
	}
}
